/**
 * Created by YangYan on 2016/5/14.
 */
$(function(){
    $(document .body).css("background","red");

    $("<input>", {
        type: "text",
        val: "Test",
        focusin: function() {
            $(this).addClass("active");
        },
        focusout: function() {
            $(this).removeClass("active");
        }
    }).appendTo("form");
    $("<div><p>Hello</p></div>").appendTo("body");
    $("img").each(function(i){
        this.src="../img/"+(i+1)+".jpg";
    });
   // console.log($("img").get(0));
    $("div").data("test",{first:19,last:"pizza"});
    $("img").attr({"src" : "../img/1.jpg","alt":"给img赋值"});
    $("p").html(function(n){
        return "这个元素的索引是"+n;
    });
    $("p").text(function(n){
        return "222这个元素的索引是"+n;
    });
    $("input").val(function(){
       return this.value+"  "+this.className;
       // console.log(this.value+"  "+this.className);
    });
    $("p").css({color:"yello",background:"pink"});
    $("p:last").offset({top:30,left:30});
   // console.log($("p:last").position());
   // console.log($("p").height());
   // console.log($("p").innerWidth());
   //  console.log($("#form1 input" ));
   //  console.log($("#form1 > input"))
   //  console.log($("label + input"));
   //  console.log($("label ~ input"));
    console.log($("li:first").text());
    console.log($("li:first-child"));
    console.log($("li:first-of-type"));
});
